package com.daqian.chance.example.web.modules.member.controller;

import com.daqian.chance.core.rest.RestResult;
import com.daqian.chance.example.web.modules.member.po.entity.Member;
import com.daqian.chance.example.web.modules.member.po.req.SuggestQueryWebReq;
import com.daqian.chance.redis.conf.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/test/redis")
public class RedisController {

    @Autowired
    private RedisService redisService;

    @GetMapping("set")
    public RestResult set(String value) {
        String testKey = "test";
        redisService.setValue(testKey, value, 100);
        return RestResult.ok(redisService.getValue(testKey));
    }

    @GetMapping("member")
    public RestResult testMember(Member member) {
        String testKey = "testMember";
        redisService.setValue(testKey, member, 100);
        return RestResult.ok(redisService.getValue(testKey));
    }

    @GetMapping("req")
    public RestResult testSuggestQueryWebRequest(SuggestQueryWebReq suggestQueryWebReq) {
        String testKey = "SuggestQueryWebRequest";
        redisService.setValue(testKey, suggestQueryWebReq, 100);
        return RestResult.ok(redisService.getValue(testKey));
    }

}
